package com.example.service;

import com.example.annotation.TestAfter;
import com.example.annotation.TestBefore;
import com.example.annotation.TestCache;
import com.example.annotation.TestSendSms;
import com.example.po.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/****
 *
 * 业务类
 */
@Service
public class TestServiceImpl implements TestService {

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    Logger logger = LoggerFactory.getLogger(getClass());

    @TestBefore("testBeforeHandler")
    @TestAfter("testAfterHandler")
    @Override
    public String getTime() {
        return simpleDateFormat.format(new Date());
    }

    @Override
    public String getInfo(long id) {
        return String.valueOf(id);
    }

    @TestCache("${user.id + addressId}")
    @Override
    public void add(User user, String addressId) {
        logger.info("add user成功...." + user.getId());
    }

    @TestSendSms("恭喜您注册成功，用户编号是:${user.id}")
    @Override
    public void send(User user) {
        logger.info("send user成功...." + user.getId());
    }
}